﻿using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Net.KKcms.Common;

public partial class ocx_land_search_advance : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        NameValueCollection nvcParam = new NameValueCollection(Request.QueryString);
        if (!Page.IsPostBack)
        {

            foreach (string key in nvcParam)
            {
                switch (key)
                {
                    case "NewsID":
                        tbx_NewsID.Text = nvcParam[key];
                        break;
                    case "NewsTitle":
                        tbx_NewsTitle.Text = nvcParam[key];
                        break;
                    case "NewsCategory":
                        ddl_NewsCategory.Text = nvcParam[key];
                        break;
                    default:
                        break;
                }
            }

        }
    }
    protected void ibtnSearch_Click(object sender, ImageClickEventArgs e)
    {
        NameValueCollection nvcParam = new NameValueCollection(Request.QueryString);
        if (tbx_NewsID.Text.Length > 0)
        {
            UrlQueryUtils.UpdateQuery(nvcParam, "NewsID", tbx_NewsID.Text, true);
        }
        else
        {
            nvcParam.Remove("NewsID");
        }
        if (tbx_NewsTitle.Text.Length > 0)
        {
            UrlQueryUtils.UpdateQuery(nvcParam, "NewsTitle", tbx_NewsTitle.Text, true);
        }
        else
        {
            nvcParam.Remove("NewsTitle");
        }
        if (ddl_NewsCategory.SelectedIndex != 0)
        {
            UrlQueryUtils.UpdateQuery(nvcParam, "NewsCategory", ddl_NewsCategory.SelectedItem.Value, true);
        }
        else
        {
            nvcParam.Remove("NewsCategory");
        }

        Response.Redirect("search.aspx?" + Net.KKcms.Common.UrlQueryUtils.GetRedirectUrl(nvcParam));
    }
}
